
package protocol.meta;

import org.json.JSONException;
import org.json.JSONObject;

import Utils.XoneUtil;

public class BindingAccountVO {

    public int type;
    public long timeDiff;
    public String rawInfo;
    public BindAccountRawInfo wbInfo;

    public void parseJson(JSONObject json) {
        if (json == null)
            return;

        type = json.optInt("type");
        timeDiff = json.optLong("timeDiff");
        String raw = XoneUtil.nullStr(json.optString("rawInfo"));
        if (raw != null) {
            try {
                wbInfo = new BindAccountRawInfo(new JSONObject(raw));
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }
    
    @Override
    public String toString() {
        return getJSONObject().toString();
    }
    
   public JSONObject getJSONObject() {
       JSONObject json = new JSONObject();
       try {
           json.put("type", type);
           json.put("timeDiff", timeDiff);
           json.put("rawInfo", wbInfo.toString());
         
       } catch (JSONException e) {
           e.printStackTrace();
       }
       
       return json;
   }
}
